# -*- coding: utf-8 -*-
# owner: shenyi

from tencentcloud.common import credential
from tencentcloud.cvm.v20170312 import cvm_client
from src.core import credentials

class Client:
    
    @staticmethod
    def cvm_client(region = None):
        """
        使用AK&SK初始化账号Client
        @param region: 地域
        @return: CvmClient
        """
        tencent_creds = credentials().tencent()
        cred = credential.Credential(
            secret_id=tencent_creds.get("access_key_id"),
            secret_key=tencent_creds.get("access_key_secret")
        )
        region = region or tencent_creds.get("region")
        client = cvm_client.CvmClient(cred, region)
        return client